package com.winner.chain_of_responsibility_pattern;

/**
 * 责任链模式在SpringAOP中的使用
 *
 * 如下是责任链入门demo
 * https://blog.csdn.net/weixin_42146366/article/details/107635676?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522164543192316780271515943%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request_id=164543192316780271515943&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~top_click~default-3-107635676.pc_search_insert_ulrmf&utm_term=%E8%B4%A3%E4%BB%BB%E9%93%BE%E6%A8%A1%E5%BC%8F&spm=1018.2226.3001.4187
 */
public class Test {
    public static void main(String[] args) {
        Handler zhangsan = new Director("张三");
        Handler lisi = new Manager("李四");
        Handler wangwu = new GeneralManager("王五");

        // 创建责任链  由客户端负责链的创建，降低了系统的耦合度；
        zhangsan.setNextHandler(lisi);
        lisi.setNextHandler(wangwu);

        // 发起请假申请
        boolean result1 = zhangsan.process(new LeaveRequest(" 赵六", 2));
        System.out.println("最终结果：" + result1);

        boolean result2 = zhangsan.process(new LeaveRequest("孙七", 4));
        System.out.println("最终结果：" + result2);

        boolean result3 = zhangsan.process(new LeaveRequest("周八", 8));
        System.out.println("最终结果：" + result3);
    }
}

